﻿using System;

namespace SoldiHive.Model
{
	[Serializable]
	public class AnalystOpinion
	{
		public DateTime? Date { get; set; }
		public string Firm { get; set; }
		public OpinionAction Action { get; set; }
		public Opinion Previous { get; set; }
		public Opinion Current { get; set; }
		public double? PriceTarget { get; set; }
		public int? OpinionsCount { get; set; }

		public AnalystOpinion()
		{
			this.Date = null;
			this.Firm = string.Empty;
			this.Action = OpinionAction.NA;
			this.Previous = Opinion.NA;
			this.Current = Opinion.NA;
			this.PriceTarget = null;
			this.OpinionsCount = null;
		}

		public override bool Equals(object obj)
		{
			if (!(obj is AnalystOpinion) || obj == null)
			{
				return false;
			}

			var analystOpinion = obj as AnalystOpinion;

			return string.Equals(this.Date, analystOpinion.Date) &&
				string.Equals(this.Action, analystOpinion.Action) &&
				string.Equals(this.Current, analystOpinion.Current) &&
				string.Equals(this.Firm, analystOpinion.Firm) &&
				string.Equals(this.OpinionsCount, analystOpinion.OpinionsCount) &&
				string.Equals(this.Previous, analystOpinion.Previous) &&
				string.Equals(this.PriceTarget, analystOpinion.PriceTarget);
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		public static bool operator ==(AnalystOpinion left, AnalystOpinion right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(AnalystOpinion left, AnalystOpinion right)
		{
			return !(left == right);
		}
	}
}
